package br.com.massai.model.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import br.com.massai.view.enums.SituacaoEnum;

@Entity
@SequenceGenerator(name = "seqFuncionario", sequenceName = "seq_funcionario", allocationSize = 1)
@NamedQueries({@NamedQuery(name = "Funcionario.findAll", query = "SELECT f FROM Funcionario f")})
@Table(name = "FUNCIONARIO", schema = "PORTAL")
public class Funcionario implements Serializable {

	private static final long serialVersionUID = -375022798784983709L;

	@Id
	@Column(name = "ID_FUNCIONARIO")
	@GeneratedValue(generator = "seqFuncionario", strategy = GenerationType.SEQUENCE)
	private Long id;

	@Column(name = "COD_TOTVS", nullable = false, unique = true)
	private String codTotvs;
	
	@Column(name = "COD_COLIGADA", nullable = false)
	private int codColigada;

	@Column(name = "NOME", length = 255, nullable = false, columnDefinition = "VARCHAR(255)")
	private String nome;

	@Column(name = "FUNCAO", length = 100, nullable = false, columnDefinition = "VARCHAR(100)")
	private String funcao;
	
	@Column(name = "EMAIL", length = 255, nullable = false, columnDefinition = "VARCHAR(255)")
	private String email;

	@Enumerated(EnumType.STRING)
	@Column(name = "SITUACAO", nullable = false, columnDefinition = "CHAR")
	private SituacaoEnum situacao;

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Funcionario)
			if(((Funcionario) obj).getCodTotvs().equals(this.getCodTotvs())) return true;
		return false;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCodTotvs() {
		return codTotvs;
	}

	public void setCodTotvs(String codTotvs) {
		this.codTotvs = codTotvs;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getFuncao() {
		return funcao;
	}

	public void setFuncao(String funcao) {
		this.funcao = funcao;
	}

	public SituacaoEnum getSituacao() {
		return situacao;
	}

	public void setSituacao(SituacaoEnum situacao) {
		this.situacao = situacao;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getCodColigada() {
		return codColigada;
	}

	public void setCodColigada(int codColigada) {
		this.codColigada = codColigada;
	}
}
